package com.liuchuan.template.controller;


import com.liuchuan.template.domain.entity.People;
import com.liuchuan.template.domain.vo.PeopleVO;
import com.liuchuan.template.service.PeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/people")
public class PeopleController {
    @Autowired
    private PeopleService peopleService;

    @GetMapping("/{id}")
    public PeopleVO getById (@PathVariable Long id){
        return peopleService.getById(id);
    }

    @PostMapping
    public PeopleVO add(@RequestBody People people){
        return peopleService.add(people);
    }

    @PutMapping
    public PeopleVO update(@RequestBody People people){
        return peopleService.update(people);
    }

    @DeleteMapping("/{id}")
    public PeopleVO deleteById (@PathVariable Long id){
        return peopleService.deleteById(id);
    }
}
